<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			var array = [12, 13, 14];
			// 数组的访问通过数组名加下标 array[0]
			// console.log(array[0]);
			// console.log(array[1]);
			// console.log(array[2]);
			// var i = 1;
			// i = i + 1  等价于：i++
			// for遍历
			// 返回数组的长度
			console.log(array.length);// 3
			for (var i = 0; i < array.length; i++) {
				console.log(i); // 0 1 2
				console.log(array[i]);
			}
			
			/* for (var i = 0; i <= array.length - 1; i++) {
				console.log(i); // 0 1 2
				console.log(array[i]);
			} */
			
			console.log('-------------');
			// 1+2+3+...+100=5050
			var sum = 0;
			for (var i = 1; i <= 100; i++) {
				console.log(i);
				sum = sum + i;
				//console.log('sum: ' + sum);
			}
			console.log(sum);
			
			// while
			var result = 0;
			var i = 0;
			while(i <= 100) {
				result = result + i;
				i++;
			}
			console.log(result);
			// console.log(0 < 3);// true
		</script>
	</head>
	<body>
	</body>
</html>
